package com.lglbc;

import java.util.ArrayList;
import java.util.List;

//-Xms6m -Xmx6m -XX:+HeapDumpOnOutOfMemoryError
public class HeapRuntimeConstantPoolOOM {
    static class OOMObject{

    }
//    public static void main(String[] args) {
//        List<String> oomObjects = new ArrayList<>();
//        int i=0;
//        while (true){
//            i++;
//            oomObjects.add(String.valueOf(i).intern());
//        }
//    }
    public static void main(String[] args) {
       String a = new StringBuilder("ja").append("va").toString();
        System.out.println(a.hashCode());
        String intern = a.intern();
        System.out.println(intern.hashCode());
        System.out.println(intern ==a);
    }
}
